//
//  sprite.cpp
//  gles1
//
//  Created by Realore Realore on 27.09.11.
//  Copyright 2011 Realore Studios. All rights reserved.
//

#include "timeengine.h"
#include "engine.h"
#import <OpenGLES/ES1/gl.h>
#import <OpenGLES/ES1/glext.h>
#import <OpenGLES/ES2/gl.h>
#import <OpenGLES/ES2/glext.h>
#import "timer.h"

// Date constructor
TEngine::TEngine(int delay,void (*infunc)())
{
    /*
    TextureID = 0;
    rotation = 0;
    x=_x;
    y=_y;
    //frames init
    totalFrames = 1; 
    currFrame = 1;
    //geometry
    SetPolygon(_width, _height);
    
    SetTextureCoords(0, 0, 1, 1);
    */
    func = infunc;
    
    m_pTimer = new CTimer(this,delay,NULL,false);
    
}

void TEngine::onTimer(const CTimer* theTimer)
{
    // Do whatever you want here
    // You can retrieve data in CTimer through theTimer->data()
    
    // Once you finish, you can stop the timer here or somewhere else.
    // the stop function will destroy CTimer object so that you don't 
    // need to delete it ( there is no way to delete it because I make 
    // the destructor in private. But you have to stop it otherwise there
    // will be memory leak)
    //printf("timer OKOK\n");
    /*
    currFrame++;
    
    if(currFrame>totalFrames-1)currFrame=0;
    SetFrame(currFrame);
    //const_cast<CTimer*>(theTimer)->stop();
     */
    func();
}

